﻿using RPAVIEW.util;
using SUNRPA.CONTROLS.IMPL.domain.constant;
using SUNRPA.CONTROLS.IMPL.domain.flowItemParam;
using System.Collections.Generic;
using System;
using System.Windows.Controls;
using SUNRPA.CONTROLS.IMPL.domain;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;

namespace RPAVIEW.views.EditPage.flows.ReadFileN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Output:BaseParamViewAction{
        public Output() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            ReadFileNParam param = ParamUtil.GetCurrentParam<ReadFileNParam>();
            FlowEditWindow window = WindowUtil.GetWindow<FlowEditWindow>();
            Input inputPage = window.General.input.Children[0] as Input;
            Type type = null;
            switch(inputPage.saveType.SelectedIndex) {
                case 0:
                    type = typeof(string);
                    ParamUtil.DefineVar(DefaultContents.RUNNING_PARAM, this.outVarName.Text, typeof(StringModel), param.OutVarName);
                    break;
                case 1:
                    type = typeof(List<string>);
                    ParamUtil.DefineVar(DefaultContents.RUNNING_PARAM, this.outVarName.Text, typeof(ListModel<string>), param.OutVarName);
                    break;
                case 2:
                    type = typeof(byte[]);
                    ParamUtil.DefineVar(DefaultContents.RUNNING_PARAM, this.outVarName.Text, typeof(OtherModel), param.OutVarName);
                    break;
                default:
                    type = typeof(string);
                    break;
            }
            this.outVarName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
        }
    }
}
